package com.cebbank.yyi.springbootapp.jingtang.controller;

import com.cebbank.yyi.springbootapp.jingtang.entity.RcDocAttachment;
import com.cebbank.yyi.springbootapp.jingtang.service.RcDocAttachmentService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 文档附件列表(RcDocAttachment)表控制层
 *
 * @author makejava
 * @since 2024-08-22 10:52:58
 */
@RestController
@RequestMapping("rcDocAttachment")
public class RcDocAttachmentController {
    /**
     * 服务对象
     */
    @Resource
    private RcDocAttachmentService rcDocAttachmentService;

    /**
     * 分页查询
     *
     * @param rcDocAttachment 筛选条件
     * @param pageRequest     分页对象
     * @return 查询结果
     */
//    @GetMapping
//    public ResponseEntity<Page<RcDocAttachment>> queryByPage(RcDocAttachment rcDocAttachment, PageRequest pageRequest) {
//        return ResponseEntity.ok(this.rcDocAttachmentService.queryByPage(rcDocAttachment, pageRequest));
//    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<RcDocAttachment> queryById(@PathVariable("id") String id) {
        return ResponseEntity.ok(this.rcDocAttachmentService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param rcDocAttachment 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<RcDocAttachment> add(RcDocAttachment rcDocAttachment) {
        return ResponseEntity.ok(this.rcDocAttachmentService.insert(rcDocAttachment));
    }

    /**
     * 编辑数据
     *
     * @param rcDocAttachment 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<RcDocAttachment> edit(RcDocAttachment rcDocAttachment) {
        return ResponseEntity.ok(this.rcDocAttachmentService.update(rcDocAttachment));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(String id) {
        return ResponseEntity.ok(this.rcDocAttachmentService.deleteById(id));
    }

}

